package model

import "go.uber.org/zap/zapcore"

type Cmk struct {
	Id           string `json:"_id"`
	KeyId        string `json:"keyid"`
	KeyBlob      []byte `json:"key_blob"`
	Creator      string `json:"creator"`
	CreationDate int64  `json:"creation_date"`
	ExpireTime   int64  `json:"expire_time"`
	Alias        string `json:"alias"`
	KeySpec      int    `json:"key_spec"`
	Origin       int    `json:"origin"`
	KeyUsage     int    `json:"key_usage"`
	KeyState     int    `json:"key_state"`
}

// CmkPartitionId 分区ID
func CmkPartitionId(id string) string {
	return "cmk:" + id
}

func (receiver *Cmk) MarshalLogObject(enc zapcore.ObjectEncoder) error {
	enc.AddString("_id", receiver.Id)
	enc.AddString("keyid", receiver.KeyId)
	enc.AddString("creator", receiver.Creator)
	enc.AddInt64("expireTime", receiver.ExpireTime)
	enc.AddInt64("creationDate", receiver.CreationDate)
	enc.AddString("alias", receiver.Alias)
	enc.AddString("id", receiver.Id)
	return nil
}
